package com.cium.aqie.highOrderFunction

import java.io.File

/**
 * @Function: 统计文件非空白字符 出现个数
 * @Author: aqie
 * @Date: 2019/9/2 14:38
 */
fun main(args: Array<String>) {
    val map = HashMap<Char, Int>()
    File("build.gradle.kts").readText().toCharArray().filterNot(Char::isWhitespace)
            .groupBy { it }.map {
                it.key to it.value.size
            }.forEach(::println)

    File("build.gradle.kts").readText().toCharArray().filterNot(Char::isWhitespace).forEach(){
        val count = map[it]
        if(count == null) map[it] = 1
        else map[it] = count + 1
    }
}